# import sys
# import glob

# sys.path.append('gen-py')
# sys.path.insert(0, glob.glob('../../lib/py/build/lib*')[0])


from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TCompactProtocol
from com.hyj.thrift.data import MyPersonService
from com.hyj.thrift.data.ttypes import *

if __name__ == '__main__':

    # Make socket
    tsocket = TSocket.TSocket('localhost', 8899)

    # Buffering is critical. Raw sockets are very slow
    transport = TTransport.TFramedTransport(tsocket)

    # Wrap in a protocol
    protocol = TCompactProtocol.TCompactProtocol(transport)

    # Create a client to use the protocol encoder
    client = MyPersonService.Client(protocol)
    person=Person(age=16,name="0612里斯")
    # Connect!
    tsocket.open()
    print(person)
    client.savePerson(person)

